set.seed(89264)
temp <- legis |> 
  dplyr::select(CMPgen, CMPecon, CMPsocial, llm_class, keywords_score) |> 
  mutate(llm_class = ordered(llm_class))

fact_scores <- MCMCpack::MCMCmixfactanal(~., data = temp, factors = 1, 
                                         burnin = 2500, mcmc = 2500,
                                         store.scores = TRUE, thin = 50,
                                         store.lambda = FALSE,  
                                         verbose = 5)

legis$Factor <- colMeans(fact_scores[,2:(ncol(fact_scores)-4)]) * -1 # need to turn
save(legis, file = "all_years_legis.RData")
